package me.zhengjie.controller;

import lombok.RequiredArgsConstructor;
import me.zhengjie.pojo.dto.DeliveryDto;
import me.zhengjie.pojo.vo.ReturnVo;
import me.zhengjie.service.DeliveryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/delivery")
@RequiredArgsConstructor
public class DeliveryController {
    private static final Logger outbound = LoggerFactory.getLogger("wcsOutbound");

    private final DeliveryService outboundService;

    //配送任务
    @PostMapping("/task")
    public ReturnVo deliveryTask(@RequestBody DeliveryDto oneFloorOutboundDto){
        outbound.info("WMS下发出库任务,请求参数：{}",oneFloorOutboundDto);
        String containerCode = oneFloorOutboundDto.getContainerCode();
        boolean b = outboundService.deliveryTask(oneFloorOutboundDto);
        if (b){
            return ReturnVo.OK(containerCode);
        }
        return ReturnVo.ng(containerCode);
    }
}
